// pages/mine/mine.js
var app=getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    order_arr: [
      {
        src: "../../images/all.png",
        text: "全部订单",
        url: "allOrder/allOrder"
      },
      {
        src: "../../images/payment.png",
        text: "待付款",
        url: "allOrder/allOrder"
      },
      {
        src: "../../images/send.png",
        text: "待发货",
        url: "allOrder/allOrder"
      },
      {
        src: "../../images/revice.png",
        text: "待收货",
        url: "allOrder/allOrder"
      }, {
        src: "../../images/address.png",
        text: "地址管理",
        url: ""
      },
      {
        src: "../../images/cancel.png",
        text: "卡卷核销",
        url: ""
      }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var userInfo = app.globalData.userInfo;
    this.setData({
      userInfo: userInfo
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  // 添加收货地址
  addAddress: function (e) {
    var src = e.currentTarget.dataset.src;
    var id = e.currentTarget.dataset.id;
    if (src) {
      wx.navigateTo({
        url: src + "?status=" + id,
      })
    } else {
      if (id == 4) {
        wx.chooseAddress({
          success: function (res) {
          }
        })
      } else if (id == 5) {
        wx.scanCode({
          success: (res) => {
            console.log(res)
          }
        })
      }

    }

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})